package com.cl.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class GetHController {
    @Value("${server-url.nacos-hello-service}")
    private String HELLO_SERVICE_URL;

    private final RestTemplate restTemplate;

    public GetHController(RestTemplate restTemplate) {
        this.restTemplate = restTemplate;
    }

    @GetMapping("/consumer/{id}")
    public String getHello(@PathVariable String id) {
        return restTemplate.getForObject(HELLO_SERVICE_URL+"/nacos/"+id,String.class);
    }
}
